package com.zhixinhuixue.zsyte.xxx.ui.viewmodel

import androidx.lifecycle.MutableLiveData
import com.zhixinhuixue.zsyte.xxx.app.api.NetUrl
import com.zhixinhuixue.zsyte.xxx.data.repository.UserRepository
import com.zhixinhuixue.zsyte.xxx.data.response.StoresRequisitionSheet
import com.zhixinhuixue.zsyte.xxx.data.response.StoresRequisitionSheetItem
import com.zhixinhuixue.zsyte.xxx.data.response.UserInfo
import me.hgj.mvvmhelper.base.BaseViewModel
import me.hgj.mvvmhelper.core.databinding.BooleanObservableField
import me.hgj.mvvmhelper.core.databinding.StringObservableField
import me.hgj.mvvmhelper.ext.rxHttpRequest
import me.hgj.mvvmhelper.net.LoadingType

/**
 * 作者　: hegaojian
 * 时间　: 2020/11/3
 * 描述　:
 */
class WLCKViewModel : BaseViewModel() {

    //账户名
    val userName = StringObservableField()

    //密码
    val password = StringObservableField()

    //是否显示明文密码（登录注册界面）
    var isShowPwd = BooleanObservableField()

    //登录请求信息
    val loginData = MutableLiveData<UserInfo>()

    //登录请求信息
    val sheetData = MutableLiveData<List<StoresRequisitionSheet>>()


    //登录请求信息
    val itemData = MutableLiveData<List<StoresRequisitionSheetItem>>()


    //登录请求信息
    val commitData = MutableLiveData<Any>()

    /**
     * 获取物料领用单
     * @param phoneNumber String
     * @param password String
     */
    fun getStoresRequisitionSheet() {
        rxHttpRequest {
            onRequest = {
                sheetData.value = UserRepository.getStoresRequisitionSheet().await()
            }
            loadingType = LoadingType.LOADING_DIALOG //选传
            loadingMessage = "正在加载数据....." // 选传
            requestCode = NetUrl.GET_STORESREQUISITIONSHEET // 如果要判断接口错误业务 - 必传
        }

    }


    /**
     * 获取物料名称
     * @param phoneNumber String
     * @param password String
     */
    fun getStoresRequisitionSheetById(StoresRequisitionSheet_Id :String) {
        rxHttpRequest {
            onRequest = {
                itemData.value = UserRepository.getStoresRequisitionSheetById(StoresRequisitionSheet_Id).await()
            }
            loadingType = LoadingType.LOADING_DIALOG //选传
            loadingMessage = "正在加载数据....." // 选传
            requestCode = NetUrl.GET_STORESREQUISITIONSHEET_ITEM // 如果要判断接口错误业务 - 必传
        }

    }


    /**
     * 获取出库
     * @param phoneNumber String
     * @param password String
     */
    fun Picking(StoresRequisitionSheet_Id: String, Material_Id: String, DeliveryLabelsItems: MutableList<String>) {
        rxHttpRequest {
            onRequest = {
                commitData.value = UserRepository.Picking(StoresRequisitionSheet_Id,Material_Id,DeliveryLabelsItems).await()
            }
            loadingType = LoadingType.LOADING_DIALOG //选传
            loadingMessage = "正在提交数据....." // 选传
            requestCode = NetUrl.Picking // 如果要判断接口错误业务 - 必传
        }

    }



}